package com.yz.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket ProductApi() {
        return (new Docket(DocumentationType.SWAGGER_2)).genericModelSubstitutes(new Class[]{DeferredResult.class}).useDefaultResponseMessages(false).forCodeGeneration(false).pathMapping("/").select().build().apiInfo(this.productApiInfo());
    }

    private ApiInfo productApiInfo() {
        return (new ApiInfoBuilder()).title("HOO 测试使用 构建RESTful API").contact(new Contact("chdxyzeos", "http://www.chdxyzeos.com", "chdxyzeos@163.com")).version("1.0").description("HOO-API 描述").license("license").licenseUrl("license url").build();
    }
}